1. Field of the Invention
This invention relates to a method and apparatus for performing a trap operation in an information handling system and, more particularly, to a method and apparatus for facilitating transfer of control from a user program to a trap program while saving state information relating to the user program.
2. Description of the Related Art
The so-called year 2000 problem, or millennium bug as it is sometimes referred to, has received considerable attention lately. The problem arises from the fact that date representations in programs, files, and databases often use a two-digit year (YY) value, representing the year 1998, for example, simply as xe2x80x9c98xe2x80x9d, with the century being understood. Programs that perform arithmetic or comparison operations on such dates may give incorrect or unexpected results when dealing with years after 1999, since the understanding as to the century may no longer be correct.
Thus, a date reference of xe2x80x9c00xe2x80x9d for the year 2000 may be erroneously interpreted as referring to the year 1900. A program making such an erroneous interpretation may determine that a credit card expiring in the year xe2x80x9c00xe2x80x9d expired in the year 1900 or that a payment due in the year xe2x80x9c00xe2x80x9d was due in 1900, with unfortunate results.
Various remediation techniques have been proposed in the prior art, such as those described in U.S. Pat. No. 5,600,836 to Alter, U.S. Pat. No. 5,630,118 to Shaughnessy, U.S. Pat. No. 5,644,762 to Soeder, U.S. Pat. No. 5,668,989 to Mao, and U.S. Pat. No. 5,761,668 to Adamchick, all incorporated herein by reference. Perhaps the most straightforward technique is to modify the original source code (e.g., COBOL code) to change all two-digit year references to four-digit year references that cannot be misinterpreted. However, this is often impractical for several reasons, including the large repository of data files in the old format that often exist.
Various other, less radical techniques may be applied to either source code or object code. On such technique, described in U.S. Pat. No. 5,600,836, is called xe2x80x9cwindowingxe2x80x9d. In windowing, two-digit year references are still understood is referring to a 100-year range, but one that is offset to include the years of interest, for example, the range 1928-2027. In this example, two-digit year references in the range 0-27 are interpreted as referring to the period 2000-2027, while two-digit year references in the range 28-99 are interpreted as referring to the period 1928-1999. While this technique must be used with caution to ensure that the year dates being processed do not fall outside the given 100-year range, it permits the use of existing data files.
Another technique, operating on object code, is that used by RTX Time Warp, part of the HDS RTX (Run Time eXtensions) Environment available from Hitachi Data Systems. Preliminarily, an object-code program is scanned for Subtract and Compare instructions having date operands that are susceptible to year 2000 failure. Each such date instruction is replaced by a xe2x80x9c00xe2x80x9d op code, and an entry for the instruction, identifying the program, the instruction location, the instruction type and the date format, is made in a registration table. When encountered at execution time, the xe2x80x9c00xe2x80x9d op code causes a suspension of execution, resulting in a transfer of control to RTX Time Warp. RTX Time Warp then looks for the instruction in the registration table and executes it while taking an appropriate corrective action. Thus, if the registered instruction is a Subtract instruction and produces a negative result (for example, if an operand of 4 representing an interval of 4 years is subtracted from a date operand 02 representing the year 2002), RTX Time Warp adds 100 to the result. Similarly, if the registered instruction is a Compare instruction (for example, comparing the operands 98 and 02 representing the year dates 1998 and 2002), RTX Time Warp determines whether the condition code resulting from the comparison operation should be reversed to produce a correct result.
While the HDS tool has the advantage of being usable in situations where source code is unavailable, it is relatively limited in its repertoire of instructions that can be remediated (Subtract and Compare instructions) as well as the remediation techniques that are available.
In general, the present invention contemplates a method and apparatus of facilitating transfer of control from a user program to a trap program while saving state information relating to the user program in an information handling system in which a processor executing a program of instructions has an execution state defined by state information stored in a program context area, the program context area including an instruction address field for storing the address of the next instruction to be executed. In accordance with the invention, there is specified a trap save area outside of the program context area for storing state information relating to the user program, as well as an address of a trap program. Upon decoding a trap instruction in the user program, the processor copies current state information from the program context area to the trap save area to save state information relating to the user program, and copies the specified trap program address into the instruction address field of the program context area to transfer control to the trap program at the specified address.
Typically, the program context area comprises a program status word, containing the instruction address field, and one or more sets of registers such as a set of general registers and a corresponding set of access registers. The trap save area and trap program address may be specified by pointers in a trap control block whose address is loaded into a general register in the program context area in response to decoding the trap instruction. The trap control block may also specify a control table that is used by the trap program, in particular a window control table if the trap program is a year 2000 remediation program, such as described in the related application referred to above.